﻿using System;

namespace Progream14
{
    //定义枚举
    public enum Gender
    {
        男,
        女,
        其他
    }
    public enum QQstate
    {
        online=1,
        offline=0,
        leave=2,
        busy=3,
        Qma=4
    }

    class Program
    {
        static void Main(string[] args)
        {
            //QQstate state = QQstate.online;
            //int n = (int)state;
            //Console.WriteLine("QQ在线枚举成员的值:"+n);
            //Console.WriteLine("QQ离线枚举成员的值:" + (int)QQstate.offline);
            //Console.WriteLine("QQ离开枚举成员的值:" + (int)QQstate.leave);
            //Console.WriteLine("QQ忙碌枚举成员的值:" + (int)QQstate.busy);
            //Console.WriteLine("QQ无聊枚举成员的值:" + (int)QQstate.Qma);

            //#region 将int转换成枚举类型
            //int n1 = 5;
            //int n2 = 4;
            //var state1 = (QQstate)n1;
            //var state2 = (QQstate)n2;
            //Console.WriteLine("qq状态：" + state1);
            //Console.WriteLine("qq状态：" + state2);


           // #region 将字符串类型转换为枚举类型
            string s = "其他";
            //将“其他”转换成Gebder
            //字符串类型转换为枚举类型语法
            Gender g = (Gender)Enum.Parse(typeof(Gender),s);
            Console.WriteLine(g);
            Console.WriteLine((int)g);
        }
    }
}
